package service.imp;

import java.util.List;

import dao.ICommentDAO;
import domain.Comment;
import service.ICommentService;

public class CommentService implements ICommentService {
	
	private ICommentDAO commentDAO;
	
	public CommentService() {
		
	}

	
	public CommentService(ICommentDAO commentDAO) {
		super();
		this.commentDAO = commentDAO;
	}


	@Override
	public void addComment(Comment comment) {
		if(comment == null) return;
		if(comment.getId() != null) return;
		commentDAO.addComment(comment);
	}

	@Override
	public void deleteComment(Comment comment) {
		if(comment == null) return;
		if(comment.getId() == null) return;
		commentDAO.deleteComment(comment);
	}

	@Override
	public List<Comment> getAllComments() {
		return commentDAO.getAllComments();
	}

	@Override
	public Comment getCommentByID(String id) {
		if(id == null) return null;
		return commentDAO.getCommentByID(id);
	}

	@Override
	public void updateComment(Comment comment) {
		if(comment == null) return;
		if(comment.getId() == null) return;
		commentDAO.updateComment(comment);
	}

	public void setCommentDAO(ICommentDAO commentDAO) {
		this.commentDAO = commentDAO;
	}

	public ICommentDAO getCommentDAO() {
		return commentDAO;
	}

}
